package com.study.es.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(indexName = "product",shards = 3,replicas = 1)
public class Product {

    @Id
    private Long id;

    /**
     * 商品名称
     * type:字段数据类型
     * analyzer:分词器类型
     * index:是否索引，默认true
     * keyword:短语，不进行分词
     * */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String title;

    //分类名称
    @Field(type = FieldType.Keyword)
    private String cetegory;

    //商品价格
    @Field(type = FieldType.Double)
    private Double price;

    //图片地址
    @Field(type = FieldType.Keyword,index = false)
    private String image;
}
